]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Use ShellApp.activate_action() to launch settings panel
authorJulian Sparber <julian@sparber.net>
Mon, 19 Feb 2024 08:40:43 +0000 (09:40 +0100)
committerJulian Sparber <julian@sparber.net>
Wed, 28 Feb 2024 10:28:06 +0000 (11:28 +0100)
`ShellApp` gained the ability to activated actions and sets the correct
platform data, therefore drop the current implementation in favor for it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3198>

js/ui/status/network.js

index 4379c63cd7f55a66c9874ad8fb82a61268b88df0..a263b41c788516cb1c9178fb3fb03bb688664b49 100644 (file)
@@ -7,6 +7,7 @@ import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
 import NM from 'gi://NM';
 import Polkit from 'gi://Polkit';
+import Shell from 'gi://Shell';
 import St from 'gi://St';
 
 import * as Main from '../main.js';
@@ -65,25 +66,13 @@ function ssidToLabel(ssid) {
 function launchSettingsPanel(panel, ...args) {
     const param = new GLib.Variant('(sav)',
         [panel, args.map(s => new GLib.Variant('s', s))]);
-    const platformData = {
-        'desktop-startup-id': new GLib.Variant('s',
-            `_TIME${global.get_current_time()}`),
-    };
-    try {
-        Gio.DBus.session.call(
-            'org.gnome.Settings',
-            '/org/gnome/Settings',
-            'org.freedesktop.Application',
-            'ActivateAction',
-            new GLib.Variant('(sava{sv})',
-                ['launch-panel', [param], platformData]),
-            null,
-            Gio.DBusCallFlags.NONE,
-            -1,
-            null);
-    } catch (e) {
-        log(`Failed to launch Settings panel: ${e.message}`);
-    }
+
+    const app = Shell.AppSystem.get_default()
+        .lookup_app('org.gnome.Settings.desktop');
+
+    app.activate_action('launch-panel', param, 0, -1, null).catch(error => {
+        log(`Failed to launch Settings panel: ${error.message}`);
+    });
 }
 
 class ItemSorter {